package com.cqhgcloud.monarch.organ.config;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.security.core.AuthenticationException;
import org.springframework.security.web.AuthenticationEntryPoint;

/**
 * @param 拦截信息
 * @author weimeilayer
 * @date 2020年1月31日
 */
public class CustomAuthenticationEntryPoint implements AuthenticationEntryPoint {
	
	@Override
	public void commence(HttpServletRequest request, HttpServletResponse response,
			AuthenticationException authException) throws IOException, ServletException {
		response.setContentType("application/json;charset=utf-8");
		PrintWriter out = response.getWriter();
		StringBuffer sb = new StringBuffer();
		sb.append("{\"status\":\"error\",\"msg\":\"");
		sb.append("未登陆!");
		sb.append("\"}");
		out.write(sb.toString());
		out.flush();
		out.close();
	}
}
